using System;
using ObjectSync;
using ObjectSync.Interfaces;
using TestModel;
using System.Threading;

namespace TestClient2
{
	class MainClass
	{
		public static void Main (string[] args)
		{
          
            ISyncable t1 = new test1();

            SyncManager.Instance.Register(ref t1);

            ISyncable t2 = new test1();
            ((test1)t2).Prop2 = 2;

            SyncManager.Instance.Register(ref t2);

            NetworkManager.Instance.StartClient("192.168.0.4", 17171);
            
            ((test1)t2).Prop1 = "Teste2";

            ((test1)t2).Prop2 = 5;


            SyncManager.Instance.Syncronize();
            int id = DateTime.Now.Millisecond;
            var r = new Random(id);
            for (int i = 0; i < 100; i++)
            {
                ((test1)t2).Prop1 = "ID:" + id;
                ((test1)t2).Prop2 = r.Next(100);
                SyncManager.Instance.Syncronize();
                Console.WriteLine("(SENDING) ID: " + id + " r:" + ((test1)t2).Prop2);
				Console.WriteLine("(RECEIVING) ID: " + ((test1)t1).Prop1 + " r:" + ((test1)t1).Prop2);
                Thread.Sleep(300);
                
            }
		}
	}
}
